<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  //改变函数的this指向, js提供了三种方法 call(),apply(),bind()
  //1.call
  var o ={
    name :'tom'
  }

  function fn (a,b){
    console.log(this)
    console.log(a+b)
  }
  fn.call(o,1,2)
  //call 第一作用是可以调用函数,第二个可以改变函数内的this指向
  //call主要作用是可以实现继承
  function Father(name,age){
    this.name=name
    this.age = age
  }
  function Son(name,age,gender){
    Father.call(this,name,age)
    this.gender = gender
  }
  var son = new Son('tom',11,'男');
  console.log(son)
</script>
</body>
</html>